home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8"?>
- <!-- ===========================================================
- Styelsheet: DrinkParams.xsl
- Category: FilteringSorting
- Sub-category: Filtering: Selecting records based on parameters
- Author: David Silverlight
- HeadGeek@xmlpitstop.com
- Created: 2001-05-16
- Description:-
- This stylesheet demonstrates filtering records based on a
- value passed in as a parameter. In this example, we are
- extracting only the records that match the parameter passed
- in.
- ================================================================ -->
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
- <xsl:output method="html" encoding="ISO-8859-1" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN" />
- <!-- Display of drink listing (note the default value) -->
- <xsl:param name="drinktype" select="'house'" />
-
- <xsl:template match="/">
- <html>
- <head>
- <title>FilteringSorting - Filtering: Selecting records based on parameters</title>
- <style type="text/css">
- H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
- H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
- .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
- TD {COLOR: darkblue; FONT-FAMILY: Arial}
- TR { background-color: beige; }
- BODY { background-color: beige; }
- </style>
- </head>
- <body>
- <xsl:apply-templates select="drinks/drink[drinktype=$drinktype]" />
- </body>
- </html>
- </xsl:template>
-
- <xsl:template match="drink">
- <xsl:if test="position() > 1">
- <hr/>
- </xsl:if>
- <xsl:apply-templates select="name" />
- <xsl:apply-templates select="directions" />
- <xsl:apply-templates select="ingredients" />
- </xsl:template>
-
- <xsl:template match="name">
- <font color="darkred" face="arial" size="5">
- <xsl:value-of select="." />
- <BR />
- <BR />
- </font>
- </xsl:template>
-
- <xsl:template match="directions">
- <font face="arial black" size="3">Directions:</font>
- <br/>
- <xsl:value-of select="." />
- <br/>
- <br/>
- </xsl:template>
-
- <xsl:template match="ingredients">
- <font face="arial black" size="3">Ingredients:</font>
- <xsl:apply-templates />
- </xsl:template>
-
- <xsl:template match="ingredient">
- <ul>
- <xsl:value-of select="." />
- </ul>
- </xsl:template>
- </xsl:stylesheet>
-